<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Routing\Router;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// 需要登录验证的路由放这里
Route::group([
    'middleware' => ['auth'],
], function (Router $router) {
    //手机充值记录
    Route::get('/recharge/record', 'OrdersController@rechargeRecord')->name('recharge.record');
    Route::get('/recharge/record/{order}', 'OrdersController@rechargeRecordDetail')->name('recharge.record.detail');

    //充值相关
    Route::get('/recharge/show-package', 'MobileRechargeController@showPackage')->name('recharge.showPackage');

    //查询运营商
    Route::get('/recharge/check-operator', 'MobileRechargeController@checkOperator')->name('recharge.checkOperator');

    //创建订单
    Route::post('/orders', 'OrdersController@store')->name('orders.store');

    //微信支付
    Route::get('payment/{order}/wechat', 'PaymentController@payByWechat')->name('payment.wechat');
    //绑定微信
    Route::get('/weixin/login', 'UserController@wxLogin')->name('wx.login');
    Route::get('/weixin/loginCallback', 'UserController@wxLoginCallback')->name('wx.loginCallback');

    //历史号码
    Route::get('/recharge/history', 'UserNumHistoriesController@edit')->name('recharge.history.edit');
    Route::post('/recharge/history/delete', 'UserNumHistoriesController@historyDelete')->name('recharge.history.delete');

    //积分相关
    Route::get('/get-credit-img', 'UserController@getCreditImg')->name('user.get.credit.img');
    Route::get('/credit/record', 'UserPromoteRecordController@record')->name('credit.record');
});

// 不需要登录验证的路由放这里
Route::group([
    'middleware' => [],
], function (Router $router) {
    //充值相关
    Route::get('/', 'HomeController@index')->name('home');
    Route::get('/recharge', 'MobileRechargeController@index')->name('recharge.index');

    //用户注册
    Route::get('/login', 'UserController@create')->name('user.create');
    Route::post('/register/verifiCode', 'UserController@verifiCode')->name('user.verifiCode');
    Route::post('/register/check-resend-time', 'UserController@checkResendTime')->name('user.checkResendTime');
    //用户注销
    Route::delete('/logout', 'UserController@logout')->name('user.logout');

    //微信支付回调
    Route::post('payment/wechat/notify', 'PaymentController@wechatNotify')->name('payment.wechat.notify');

    //充值回调
    Route::post('recharge/callback', 'MobileRechargeController@rechargeCallback')->name('recharge.callback');

    //查询余额
    Route::get('recharge/getbalance', 'MobileRechargeController@responseBalance')->name('recharge.getbalance');

});
